from rest_framework import serializers
from goods.models import SPU,GoodsCategory,Brand
from celery_tasks.static_html.tasks import get_detail_html
from django.db import transaction

from goods.models import SPUSpecification


class SPUSerializer(serializers.ModelSerializer):
    '序列化器'
    brand = serializers.StringRelatedField(read_only=True)
    brand_id = serializers.IntegerField()
    category1_id = serializers.IntegerField()
    category2_id = serializers.IntegerField()
    category3_id = serializers.IntegerField()
    class Meta:
        model = SPU
        fields = '__all__'
        extra_kwargs = {
            'category1': {'required': False, },
            'category2': {'required': False, },
            'category3': {'required': False, }
        }

class BrandSerializer(serializers.ModelSerializer):
    """品牌"""
    class Meta:
        # 指定模型类
        model = Brand
        fields = '__all__'





